﻿//create the XMLHTTP object in different browsers
function XMLHTTP(){
    this.getXMLHTTP=function()
     {
        var XMLHTTP = null;
        if (window.ActiveXObject) 
        {
            try {
                XMLHTTP = new ActiveXObject("Msxml2.XMLHTTP");
            } 
            catch (e)
            {
                try {
                    XMLHTTP = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {
                }
            }
        } 
        else if (window.XMLHttpRequest) {
            try {
                XMLHTTP = new XMLHttpRequest( );
            } catch (e) {
            }
        }
        return XMLHTTP;
    }
    //send get request
    this.sendGetRequest=function(url)
    {
        if (XMLHTTP != null) {
            XMLHTTP.open("GET", url);
            XMLHTTP.onreadystatechange = stateChanged;
            XMLHTTP.send(null);
        }
    }
    //send post request
    this.sendPostRequest=function(url,parameterpairs)
    {
        if (XMLHTTP != null) {
            XMLHTTP.open("POST", url);
            XMLHTTP.onreadystatechange = stateChanged;
            XMLHTTP.send(parameterpairs);
        }
    }
    this.stateChanged=function( ) {
        if (XMLHTTP.readyState == 4 && XMLHTTP.status == 200) {
            window.alert(XMLHTTP.responseText);
        }
    }
}
alert("xx");
